package com.ly.talent.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ly.common.annotation.Log;
import com.ly.common.core.controller.BaseController;
import com.ly.common.core.domain.AjaxResult;
import com.ly.common.enums.BusinessType;
import com.ly.talent.domain.TalentSpecialty;
import com.ly.talent.service.ITalentSpecialtyService;
import com.ly.common.utils.poi.ExcelUtil;
import com.ly.common.core.page.TableDataInfo;

/**
 * 学科信息Controller
 * 
 * @author sfli
 * @date 2021-03-02
 */
@RestController
@RequestMapping("/talent/talentSpecialty")
public class TalentSpecialtyController extends BaseController
{
    @Autowired
    private ITalentSpecialtyService talentSpecialtyService;

    /**
     * 查询学科信息列表
     */
    @PreAuthorize("@ss.hasPermi('talent:talentSpecialty:list')")
    @GetMapping("/list")
    public TableDataInfo list(TalentSpecialty talentSpecialty)
    {
        startPage();
        List<TalentSpecialty> list = talentSpecialtyService.selectTalentSpecialtyList(talentSpecialty);
        return getDataTable(list);
    }

    /**
     * 导出学科信息列表
     */
    @PreAuthorize("@ss.hasPermi('talent:talentSpecialty:export')")
    @Log(title = "学科信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TalentSpecialty talentSpecialty)
    {
        List<TalentSpecialty> list = talentSpecialtyService.selectTalentSpecialtyList(talentSpecialty);
        ExcelUtil<TalentSpecialty> util = new ExcelUtil<TalentSpecialty>(TalentSpecialty.class);
        return util.exportExcel(list, "talentSpecialty");
    }

    /**
     * 获取学科信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('talent:talentSpecialty:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(talentSpecialtyService.selectTalentSpecialtyById(id));
    }

    /**
     * 新增学科信息
     */
    @PreAuthorize("@ss.hasPermi('talent:talentSpecialty:add')")
    @Log(title = "学科信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TalentSpecialty talentSpecialty)
    {
        return toAjax(talentSpecialtyService.insertTalentSpecialty(talentSpecialty));
    }

    /**
     * 修改学科信息
     */
    @PreAuthorize("@ss.hasPermi('talent:talentSpecialty:edit')")
    @Log(title = "学科信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TalentSpecialty talentSpecialty)
    {
        return toAjax(talentSpecialtyService.updateTalentSpecialty(talentSpecialty));
    }

    /**
     * 删除学科信息
     */
    @PreAuthorize("@ss.hasPermi('talent:talentSpecialty:remove')")
    @Log(title = "学科信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(talentSpecialtyService.deleteTalentSpecialtyByIds(ids));
    }
}
